/**
 * 针对S2500跨路内存访问测试
 * @file crossCpuMemoryTest.c
 * @author yeqiang@greatwall.com.cn
 * @brief
 * @version 0.1
 * @date 2022-08-22
 *
 * @copyright Copyright (c) 2022
 *
 */
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sched.h>
#include <errno.h>
#include <pthread.h>

// GB
#define BUFFER_SIZE (1024 * 1024 * 1024l)
#define BLOCK_SIZE (1024 * 1024)

/* Return the UNIX time in microseconds */
long long
ustime(void)
{
    struct timeval tv;
    long long ust;

    gettimeofday(&tv, NULL);
    ust = ((long long)tv.tv_sec) * 1000000;
    ust += tv.tv_usec;
    return ust;
}

void *memoryTest(void *arg)
{
    sleep(600);
    return NULL;
}

int main(int argc, char *argv[])
{
    pid_t pid = getpid();
    printf("pid=%d\n", pid);

    int cpuid = 0;

    for (int i = 0; i < 1000; i++)
    {
        pthread_t thread;
        int err = pthread_create(&thread, NULL, memoryTest, NULL);
        if (err != 0)
        {
            printf("memoryTest线程创建失败\n");
        }
    }
    sleep(600);

    return 0;
}